package com.zhouxiao.multithreading.runningcallback;

/**
 * @author 周明阳
 * mail:gqzmy@outlook.com
 * 时间:2018-03-13 10:02
 */

public class Rabbit extends Animal {

    public Rabbit() {
        setName("兔子");
    }

    @Override
    public void runing() {
        while (flag) {
            double dis = 0.5;
            length -= dis;
            System.out.println("~~~~~~~~~~~兔子跑了" + dis + "米，距离终点还有" + length + "米~~~~~~~~~~~");
            if (length <= 0) {
                length = 0;
                System.out.println("兔子获得了胜利");
                if (calltoback != null) {
                    flag = false;
                    calltoback.win();
                }
            }
        }
    }
}
